using System; 
using System.Text; 
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration; 
using System.Xml; 
using System.Xml.Serialization;
using SubSonic; 
using SubSonic.Utilities;
namespace DataAccess{
    /// <summary>
    /// Strongly-typed collection for the ExpProvince class.
    /// </summary>
    [Serializable]
    public partial class ExpProvinceCollection : ReadOnlyList<ExpProvince, ExpProvinceCollection>
    {        
        public ExpProvinceCollection() {}
    }
    /// <summary>
    /// This is  Read-only wrapper class for the ExpProvince view.
    /// </summary>
    [Serializable]
    public partial class ExpProvince : ReadOnlyRecord<ExpProvince>, IReadOnlyRecord
    {
    
	    #region Default Settings
	    protected static void SetSQLProps() 
	    {
		    GetTableSchema();
	    }
	    #endregion
        #region Schema Accessor
	    public static TableSchema.Table Schema
        {
            get
            {
                if (BaseSchema == null)
                {
                    SetSQLProps();
                }
                return BaseSchema;
            }
        }
    	
        private static void GetTableSchema() 
        {
            if(!IsSchemaInitialized)
            {
                //Schema declaration
                TableSchema.Table schema = new TableSchema.Table("ExpProvince", TableType.View, DataService.GetInstance("DataAccess"));
                schema.Columns = new TableSchema.TableColumnCollection();
                schema.SchemaName = @"dbo";
                //columns
                
                TableSchema.TableColumn colvarProvinceName = new TableSchema.TableColumn(schema);
                colvarProvinceName.ColumnName = "ProvinceName";
                colvarProvinceName.DataType = DbType.String;
                colvarProvinceName.MaxLength = -1;
                colvarProvinceName.AutoIncrement = false;
                colvarProvinceName.IsNullable = true;
                colvarProvinceName.IsPrimaryKey = false;
                colvarProvinceName.IsForeignKey = false;
                colvarProvinceName.IsReadOnly = false;
                
                schema.Columns.Add(colvarProvinceName);
                
                TableSchema.TableColumn colvarName = new TableSchema.TableColumn(schema);
                colvarName.ColumnName = "Name";
                colvarName.DataType = DbType.String;
                colvarName.MaxLength = -1;
                colvarName.AutoIncrement = false;
                colvarName.IsNullable = true;
                colvarName.IsPrimaryKey = false;
                colvarName.IsForeignKey = false;
                colvarName.IsReadOnly = false;
                
                schema.Columns.Add(colvarName);
                
                TableSchema.TableColumn colvarFamily = new TableSchema.TableColumn(schema);
                colvarFamily.ColumnName = "Family";
                colvarFamily.DataType = DbType.String;
                colvarFamily.MaxLength = -1;
                colvarFamily.AutoIncrement = false;
                colvarFamily.IsNullable = true;
                colvarFamily.IsPrimaryKey = false;
                colvarFamily.IsForeignKey = false;
                colvarFamily.IsReadOnly = false;
                
                schema.Columns.Add(colvarFamily);
                
                TableSchema.TableColumn colvarAddress = new TableSchema.TableColumn(schema);
                colvarAddress.ColumnName = "Address";
                colvarAddress.DataType = DbType.String;
                colvarAddress.MaxLength = -1;
                colvarAddress.AutoIncrement = false;
                colvarAddress.IsNullable = true;
                colvarAddress.IsPrimaryKey = false;
                colvarAddress.IsForeignKey = false;
                colvarAddress.IsReadOnly = false;
                
                schema.Columns.Add(colvarAddress);
                
                TableSchema.TableColumn colvarMobile = new TableSchema.TableColumn(schema);
                colvarMobile.ColumnName = "Mobile";
                colvarMobile.DataType = DbType.String;
                colvarMobile.MaxLength = -1;
                colvarMobile.AutoIncrement = false;
                colvarMobile.IsNullable = true;
                colvarMobile.IsPrimaryKey = false;
                colvarMobile.IsForeignKey = false;
                colvarMobile.IsReadOnly = false;
                
                schema.Columns.Add(colvarMobile);
                
                TableSchema.TableColumn colvarTelephone = new TableSchema.TableColumn(schema);
                colvarTelephone.ColumnName = "Telephone";
                colvarTelephone.DataType = DbType.String;
                colvarTelephone.MaxLength = -1;
                colvarTelephone.AutoIncrement = false;
                colvarTelephone.IsNullable = true;
                colvarTelephone.IsPrimaryKey = false;
                colvarTelephone.IsForeignKey = false;
                colvarTelephone.IsReadOnly = false;
                
                schema.Columns.Add(colvarTelephone);
                
                TableSchema.TableColumn colvarNationalCode = new TableSchema.TableColumn(schema);
                colvarNationalCode.ColumnName = "NationalCode";
                colvarNationalCode.DataType = DbType.String;
                colvarNationalCode.MaxLength = -1;
                colvarNationalCode.AutoIncrement = false;
                colvarNationalCode.IsNullable = true;
                colvarNationalCode.IsPrimaryKey = false;
                colvarNationalCode.IsForeignKey = false;
                colvarNationalCode.IsReadOnly = false;
                
                schema.Columns.Add(colvarNationalCode);
                
                TableSchema.TableColumn colvarProvinceId = new TableSchema.TableColumn(schema);
                colvarProvinceId.ColumnName = "ProvinceId";
                colvarProvinceId.DataType = DbType.Int32;
                colvarProvinceId.MaxLength = 0;
                colvarProvinceId.AutoIncrement = false;
                colvarProvinceId.IsNullable = true;
                colvarProvinceId.IsPrimaryKey = false;
                colvarProvinceId.IsForeignKey = false;
                colvarProvinceId.IsReadOnly = false;
                
                schema.Columns.Add(colvarProvinceId);
                
                TableSchema.TableColumn colvarEmailAddress = new TableSchema.TableColumn(schema);
                colvarEmailAddress.ColumnName = "EmailAddress";
                colvarEmailAddress.DataType = DbType.String;
                colvarEmailAddress.MaxLength = -1;
                colvarEmailAddress.AutoIncrement = false;
                colvarEmailAddress.IsNullable = true;
                colvarEmailAddress.IsPrimaryKey = false;
                colvarEmailAddress.IsForeignKey = false;
                colvarEmailAddress.IsReadOnly = false;
                
                schema.Columns.Add(colvarEmailAddress);
                
                TableSchema.TableColumn colvarId = new TableSchema.TableColumn(schema);
                colvarId.ColumnName = "ID";
                colvarId.DataType = DbType.Int32;
                colvarId.MaxLength = 0;
                colvarId.AutoIncrement = false;
                colvarId.IsNullable = false;
                colvarId.IsPrimaryKey = false;
                colvarId.IsForeignKey = false;
                colvarId.IsReadOnly = false;
                
                schema.Columns.Add(colvarId);
                
                TableSchema.TableColumn colvarUserName = new TableSchema.TableColumn(schema);
                colvarUserName.ColumnName = "UserName";
                colvarUserName.DataType = DbType.String;
                colvarUserName.MaxLength = -1;
                colvarUserName.AutoIncrement = false;
                colvarUserName.IsNullable = true;
                colvarUserName.IsPrimaryKey = false;
                colvarUserName.IsForeignKey = false;
                colvarUserName.IsReadOnly = false;
                
                schema.Columns.Add(colvarUserName);
                
                
                BaseSchema = schema;
                //add this schema to the provider
                //so we can query it later
                DataService.Providers["DataAccess"].AddSchema("ExpProvince",schema);
            }
        }
        #endregion
        
        #region Query Accessor
	    public static Query CreateQuery()
	    {
		    return new Query(Schema);
	    }
	    #endregion
	    
	    #region .ctors
	    public ExpProvince()
	    {
            SetSQLProps();
            SetDefaults();
            MarkNew();
        }
        public ExpProvince(bool useDatabaseDefaults)
	    {
		    SetSQLProps();
		    if(useDatabaseDefaults)
		    {
				ForceDefaults();
			}
			MarkNew();
	    }
	    
	    public ExpProvince(object keyID)
	    {
		    SetSQLProps();
		    LoadByKey(keyID);
	    }
    	 
	    public ExpProvince(string columnName, object columnValue)
        {
            SetSQLProps();
            LoadByParam(columnName,columnValue);
        }
        
	    #endregion
	    
	    #region Props
	    
          
        [XmlAttribute("ProvinceName")]
        [Bindable(true)]
        public string ProvinceName 
	    {
		    get
		    {
			    return GetColumnValue<string>("ProvinceName");
		    }
            set 
		    {
			    SetColumnValue("ProvinceName", value);
            }
        }
	      
        [XmlAttribute("Name")]
        [Bindable(true)]
        public string Name 
	    {
		    get
		    {
			    return GetColumnValue<string>("Name");
		    }
            set 
		    {
			    SetColumnValue("Name", value);
            }
        }
	      
        [XmlAttribute("Family")]
        [Bindable(true)]
        public string Family 
	    {
		    get
		    {
			    return GetColumnValue<string>("Family");
		    }
            set 
		    {
			    SetColumnValue("Family", value);
            }
        }
	      
        [XmlAttribute("Address")]
        [Bindable(true)]
        public string Address 
	    {
		    get
		    {
			    return GetColumnValue<string>("Address");
		    }
            set 
		    {
			    SetColumnValue("Address", value);
            }
        }
	      
        [XmlAttribute("Mobile")]
        [Bindable(true)]
        public string Mobile 
	    {
		    get
		    {
			    return GetColumnValue<string>("Mobile");
		    }
            set 
		    {
			    SetColumnValue("Mobile", value);
            }
        }
	      
        [XmlAttribute("Telephone")]
        [Bindable(true)]
        public string Telephone 
	    {
		    get
		    {
			    return GetColumnValue<string>("Telephone");
		    }
            set 
		    {
			    SetColumnValue("Telephone", value);
            }
        }
	      
        [XmlAttribute("NationalCode")]
        [Bindable(true)]
        public string NationalCode 
	    {
		    get
		    {
			    return GetColumnValue<string>("NationalCode");
		    }
            set 
		    {
			    SetColumnValue("NationalCode", value);
            }
        }
	      
        [XmlAttribute("ProvinceId")]
        [Bindable(true)]
        public int? ProvinceId 
	    {
		    get
		    {
			    return GetColumnValue<int?>("ProvinceId");
		    }
            set 
		    {
			    SetColumnValue("ProvinceId", value);
            }
        }
	      
        [XmlAttribute("EmailAddress")]
        [Bindable(true)]
        public string EmailAddress 
	    {
		    get
		    {
			    return GetColumnValue<string>("EmailAddress");
		    }
            set 
		    {
			    SetColumnValue("EmailAddress", value);
            }
        }
	      
        [XmlAttribute("Id")]
        [Bindable(true)]
        public int Id 
	    {
		    get
		    {
			    return GetColumnValue<int>("ID");
		    }
            set 
		    {
			    SetColumnValue("ID", value);
            }
        }
	      
        [XmlAttribute("UserName")]
        [Bindable(true)]
        public string UserName 
	    {
		    get
		    {
			    return GetColumnValue<string>("UserName");
		    }
            set 
		    {
			    SetColumnValue("UserName", value);
            }
        }
	    
	    #endregion
    
	    #region Columns Struct
	    public struct Columns
	    {
		    
		    
            public static string ProvinceName = @"ProvinceName";
            
            public static string Name = @"Name";
            
            public static string Family = @"Family";
            
            public static string Address = @"Address";
            
            public static string Mobile = @"Mobile";
            
            public static string Telephone = @"Telephone";
            
            public static string NationalCode = @"NationalCode";
            
            public static string ProvinceId = @"ProvinceId";
            
            public static string EmailAddress = @"EmailAddress";
            
            public static string Id = @"ID";
            
            public static string UserName = @"UserName";
            
	    }
	    #endregion
	    
	    
	    #region IAbstractRecord Members
        public new CT GetColumnValue<CT>(string columnName) {
            return base.GetColumnValue<CT>(columnName);
        }
        public object GetColumnValue(string columnName) {
            return base.GetColumnValue<object>(columnName);
        }
        #endregion
	    
    }
}
